3.1.70 \(\int \frac {(a+b \tan (e+f x))^3 (A+B \tan (e+f x)+C \tan ^2(e+f x))}{c+d \tan (e+f x)} \, dx\) [70]

3.1.70.1 Optimal result
3.1.70.2 Mathematica [C] (verified)
3.1.70.3 Rubi [A] (verified)
3.1.70.4 Maple [A] (verified)
3.1.70.5 Fricas [A] (verification not implemented)
3.1.70.6 Sympy [C] (verification not implemented)
3.1.70.7 Maxima [A] (verification not implemented)
3.1.70.8 Giac [A] (verification not implemented)
3.1.70.9 Mupad [B] (verification not implemented)

3.1.70.1 Optimal result

Integrand size = 45, antiderivative size = 337 \[ \int \frac {(a+b \tan (e+f x))^3 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{c+d \tan (e+f x)} \, dx=\frac {\left (a^3 (A c-c C+B d)-3 a b^2 (A c-c C+B d)-3 a^2 b (B c-(A-C) d)+b^3 (B c-(A-C) d)\right ) x}{c^2+d^2}-\frac {\left (3 a^2 b (A c-c C+B d)-b^3 (A c-c C+B d)+a^3 (B c-(A-C) d)-3 a b^2 (B c-(A-C) d)\right ) \log (\cos (e+f x))}{\left (c^2+d^2\right ) f}-\frac {(b c-a d)^3 \left (c^2 C-B c d+A d^2\right ) \log (c+d \tan (e+f x))}{d^4 \left (c^2+d^2\right ) f}+\frac {b \left (b (A b+a B-b C) d^2+(b c-a d) (b c C-b B d-a C d)\right ) \tan (e+f x)}{d^3 f}-\frac {(b c C-b B d-a C d) (a+b \tan (e+f x))^2}{2 d^2 f}+\frac {C (a+b \tan (e+f x))^3}{3 d f} \]

output
(a^3*(A*c+B*d-C*c)-3*a*b^2*(A*c+B*d-C*c)-3*a^2*b*(B*c-(A-C)*d)+b^3*(B*c-(A 
-C)*d))*x/(c^2+d^2)-(3*a^2*b*(A*c+B*d-C*c)-b^3*(A*c+B*d-C*c)+a^3*(B*c-(A-C 
)*d)-3*a*b^2*(B*c-(A-C)*d))*ln(cos(f*x+e))/(c^2+d^2)/f-(-a*d+b*c)^3*(A*d^2 
-B*c*d+C*c^2)*ln(c+d*tan(f*x+e))/d^4/(c^2+d^2)/f+b*(b*(A*b+B*a-C*b)*d^2+(- 
a*d+b*c)*(-B*b*d-C*a*d+C*b*c))*tan(f*x+e)/d^3/f-1/2*(-B*b*d-C*a*d+C*b*c)*( 
a+b*tan(f*x+e))^2/d^2/f+1/3*C*(a+b*tan(f*x+e))^3/d/f
 
3.1.70.2 Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 4.86 (sec) , antiderivative size = 258, normalized size of antiderivative = 0.77 \[ \int \frac {(a+b \tan (e+f x))^3 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{c+d \tan (e+f x)} \, dx=\frac {\frac {3 (a+i b)^3 (-i A+B+i C) d^2 \log (i-\tan (e+f x))}{c+i d}+\frac {3 (a-i b)^3 (i A+B-i C) d^2 \log (i+\tan (e+f x))}{c-i d}+\frac {6 (-b c+a d)^3 \left (c^2 C-B c d+A d^2\right ) \log (c+d \tan (e+f x))}{d^2 \left (c^2+d^2\right )}+6 b^2 (A b+a B-b C) d \tan (e+f x)-\frac {6 b (b c-a d) (-b c C+b B d+a C d) \tan (e+f x)}{d}-3 (b c C-b B d-a C d) (a+b \tan (e+f x))^2+2 C d (a+b \tan (e+f x))^3}{6 d^2 f} \]

input
Integrate[((a + b*Tan[e + f*x])^3*(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2)) 
/(c + d*Tan[e + f*x]),x]
 
output
((3*(a + I*b)^3*((-I)*A + B + I*C)*d^2*Log[I - Tan[e + f*x]])/(c + I*d) + 
(3*(a - I*b)^3*(I*A + B - I*C)*d^2*Log[I + Tan[e + f*x]])/(c - I*d) + (6*( 
-(b*c) + a*d)^3*(c^2*C - B*c*d + A*d^2)*Log[c + d*Tan[e + f*x]])/(d^2*(c^2 
 + d^2)) + 6*b^2*(A*b + a*B - b*C)*d*Tan[e + f*x] - (6*b*(b*c - a*d)*(-(b* 
c*C) + b*B*d + a*C*d)*Tan[e + f*x])/d - 3*(b*c*C - b*B*d - a*C*d)*(a + b*T 
an[e + f*x])^2 + 2*C*d*(a + b*Tan[e + f*x])^3)/(6*d^2*f)
 
3.1.70.3 Rubi [A] (verified)

Time = 2.42 (sec) , antiderivative size = 359, normalized size of antiderivative = 1.07, number of steps used = 16, number of rules used = 15, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.333, Rules used = {3042, 4130, 27, 3042, 4130, 27, 3042, 4120, 25, 3042, 4109, 3042, 3956, 4100, 16}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int \frac {(a+b \tan (e+f x))^3 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{c+d \tan (e+f x)} \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {(a+b \tan (e+f x))^3 \left (A+B \tan (e+f x)+C \tan (e+f x)^2\right )}{c+d \tan (e+f x)}dx\)

\(\Big \downarrow \) 4130

\(\displaystyle \frac {\int -\frac {3 (a+b \tan (e+f x))^2 \left ((b c C-a d C-b B d) \tan ^2(e+f x)-(A b-C b+a B) d \tan (e+f x)+b c C-a A d\right )}{c+d \tan (e+f x)}dx}{3 d}+\frac {C (a+b \tan (e+f x))^3}{3 d f}\)

\(\Big \downarrow \) 27

\(\displaystyle \frac {C (a+b \tan (e+f x))^3}{3 d f}-\frac {\int \frac {(a+b \tan (e+f x))^2 \left ((b c C-a d C-b B d) \tan ^2(e+f x)-(A b-C b+a B) d \tan (e+f x)+b c C-a A d\right )}{c+d \tan (e+f x)}dx}{d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {C (a+b \tan (e+f x))^3}{3 d f}-\frac {\int \frac {(a+b \tan (e+f x))^2 \left ((b c C-a d C-b B d) \tan (e+f x)^2-(A b-C b+a B) d \tan (e+f x)+b c C-a A d\right )}{c+d \tan (e+f x)}dx}{d}\)

\(\Big \downarrow \) 4130

\(\displaystyle \frac {C (a+b \tan (e+f x))^3}{3 d f}-\frac {\frac {\int \frac {2 (a+b \tan (e+f x)) \left (-c (c C-B d) b^2+2 a c C d b-a^2 A d^2-\left (b (A b-C b+a B) d^2+(b c-a d) (b c C-a d C-b B d)\right ) \tan ^2(e+f x)-\left (B a^2+2 b (A-C) a-b^2 B\right ) d^2 \tan (e+f x)\right )}{c+d \tan (e+f x)}dx}{2 d}+\frac {(-a C d-b B d+b c C) (a+b \tan (e+f x))^2}{2 d f}}{d}\)

\(\Big \downarrow \) 27

\(\displaystyle \frac {C (a+b \tan (e+f x))^3}{3 d f}-\frac {\frac {\int \frac {(a+b \tan (e+f x)) \left (-c (c C-B d) b^2+2 a c C d b-a^2 A d^2-\left (b (A b-C b+a B) d^2+(b c-a d) (b c C-a d C-b B d)\right ) \tan ^2(e+f x)-\left (B a^2+2 b (A-C) a-b^2 B\right ) d^2 \tan (e+f x)\right )}{c+d \tan (e+f x)}dx}{d}+\frac {(-a C d-b B d+b c C) (a+b \tan (e+f x))^2}{2 d f}}{d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {C (a+b \tan (e+f x))^3}{3 d f}-\frac {\frac {\int \frac {(a+b \tan (e+f x)) \left (-c (c C-B d) b^2+2 a c C d b-a^2 A d^2-\left (b (A b-C b+a B) d^2+(b c-a d) (b c C-a d C-b B d)\right ) \tan (e+f x)^2-\left (B a^2+2 b (A-C) a-b^2 B\right ) d^2 \tan (e+f x)\right )}{c+d \tan (e+f x)}dx}{d}+\frac {(-a C d-b B d+b c C) (a+b \tan (e+f x))^2}{2 d f}}{d}\)

\(\Big \downarrow \) 4120

\(\displaystyle \frac {C (a+b \tan (e+f x))^3}{3 d f}-\frac {\frac {-\frac {\int -\frac {c \left (C c^2-B d c+(A-C) d^2\right ) b^3-3 a c d (c C-B d) b^2+3 a^2 c C d^2 b-a^3 A d^3-\left (-\left (\left (C c^3-B d c^2+(A-C) d^2 c+B d^3\right ) b^3\right )+3 a d \left (C c^2-B d c+(A-C) d^2\right ) b^2-3 a^2 d^2 (c C-B d) b+a^3 C d^3\right ) \tan ^2(e+f x)-\left (B a^3+3 b (A-C) a^2-3 b^2 B a-b^3 (A-C)\right ) d^3 \tan (e+f x)}{c+d \tan (e+f x)}dx}{d}-\frac {b \tan (e+f x) \left (b d^2 (a B+A b-b C)+(b c-a d) (-a C d-b B d+b c C)\right )}{d f}}{d}+\frac {(-a C d-b B d+b c C) (a+b \tan (e+f x))^2}{2 d f}}{d}\)

\(\Big \downarrow \) 25

\(\displaystyle \frac {C (a+b \tan (e+f x))^3}{3 d f}-\frac {\frac {\frac {\int \frac {c \left (C c^2-B d c+(A-C) d^2\right ) b^3-3 a c d (c C-B d) b^2+3 a^2 c C d^2 b-a^3 A d^3-\left (-\left (\left (C c^3-B d c^2+(A-C) d^2 c+B d^3\right ) b^3\right )+3 a d \left (C c^2-B d c+(A-C) d^2\right ) b^2-3 a^2 d^2 (c C-B d) b+a^3 C d^3\right ) \tan ^2(e+f x)-\left (B a^3+3 b (A-C) a^2-3 b^2 B a-b^3 (A-C)\right ) d^3 \tan (e+f x)}{c+d \tan (e+f x)}dx}{d}-\frac {b \tan (e+f x) \left (b d^2 (a B+A b-b C)+(b c-a d) (-a C d-b B d+b c C)\right )}{d f}}{d}+\frac {(-a C d-b B d+b c C) (a+b \tan (e+f x))^2}{2 d f}}{d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {C (a+b \tan (e+f x))^3}{3 d f}-\frac {\frac {\frac {\int \frac {c \left (C c^2-B d c+(A-C) d^2\right ) b^3-3 a c d (c C-B d) b^2+3 a^2 c C d^2 b-a^3 A d^3-\left (-\left (\left (C c^3-B d c^2+(A-C) d^2 c+B d^3\right ) b^3\right )+3 a d \left (C c^2-B d c+(A-C) d^2\right ) b^2-3 a^2 d^2 (c C-B d) b+a^3 C d^3\right ) \tan (e+f x)^2-\left (B a^3+3 b (A-C) a^2-3 b^2 B a-b^3 (A-C)\right ) d^3 \tan (e+f x)}{c+d \tan (e+f x)}dx}{d}-\frac {b \tan (e+f x) \left (b d^2 (a B+A b-b C)+(b c-a d) (-a C d-b B d+b c C)\right )}{d f}}{d}+\frac {(-a C d-b B d+b c C) (a+b \tan (e+f x))^2}{2 d f}}{d}\)

\(\Big \downarrow \) 4109

\(\displaystyle \frac {C (a+b \tan (e+f x))^3}{3 d f}-\frac {\frac {\frac {-\frac {d^3 \left (a^3 (B c-d (A-C))+3 a^2 b (A c+B d-c C)-3 a b^2 (B c-d (A-C))-b^3 (A c+B d-c C)\right ) \int \tan (e+f x)dx}{c^2+d^2}+\frac {(b c-a d)^3 \left (A d^2-B c d+c^2 C\right ) \int \frac {\tan ^2(e+f x)+1}{c+d \tan (e+f x)}dx}{c^2+d^2}-\frac {d^3 x \left (a^3 (A c+B d-c C)-3 a^2 b (B c-d (A-C))-3 a b^2 (A c+B d-c C)+b^3 (B c-d (A-C))\right )}{c^2+d^2}}{d}-\frac {b \tan (e+f x) \left (b d^2 (a B+A b-b C)+(b c-a d) (-a C d-b B d+b c C)\right )}{d f}}{d}+\frac {(-a C d-b B d+b c C) (a+b \tan (e+f x))^2}{2 d f}}{d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {C (a+b \tan (e+f x))^3}{3 d f}-\frac {\frac {\frac {-\frac {d^3 \left (a^3 (B c-d (A-C))+3 a^2 b (A c+B d-c C)-3 a b^2 (B c-d (A-C))-b^3 (A c+B d-c C)\right ) \int \tan (e+f x)dx}{c^2+d^2}+\frac {(b c-a d)^3 \left (A d^2-B c d+c^2 C\right ) \int \frac {\tan (e+f x)^2+1}{c+d \tan (e+f x)}dx}{c^2+d^2}-\frac {d^3 x \left (a^3 (A c+B d-c C)-3 a^2 b (B c-d (A-C))-3 a b^2 (A c+B d-c C)+b^3 (B c-d (A-C))\right )}{c^2+d^2}}{d}-\frac {b \tan (e+f x) \left (b d^2 (a B+A b-b C)+(b c-a d) (-a C d-b B d+b c C)\right )}{d f}}{d}+\frac {(-a C d-b B d+b c C) (a+b \tan (e+f x))^2}{2 d f}}{d}\)

\(\Big \downarrow \) 3956

\(\displaystyle \frac {C (a+b \tan (e+f x))^3}{3 d f}-\frac {\frac {\frac {\frac {(b c-a d)^3 \left (A d^2-B c d+c^2 C\right ) \int \frac {\tan (e+f x)^2+1}{c+d \tan (e+f x)}dx}{c^2+d^2}+\frac {d^3 \log (\cos (e+f x)) \left (a^3 (B c-d (A-C))+3 a^2 b (A c+B d-c C)-3 a b^2 (B c-d (A-C))-b^3 (A c+B d-c C)\right )}{f \left (c^2+d^2\right )}-\frac {d^3 x \left (a^3 (A c+B d-c C)-3 a^2 b (B c-d (A-C))-3 a b^2 (A c+B d-c C)+b^3 (B c-d (A-C))\right )}{c^2+d^2}}{d}-\frac {b \tan (e+f x) \left (b d^2 (a B+A b-b C)+(b c-a d) (-a C d-b B d+b c C)\right )}{d f}}{d}+\frac {(-a C d-b B d+b c C) (a+b \tan (e+f x))^2}{2 d f}}{d}\)

\(\Big \downarrow \) 4100

\(\displaystyle \frac {C (a+b \tan (e+f x))^3}{3 d f}-\frac {\frac {\frac {\frac {(b c-a d)^3 \left (A d^2-B c d+c^2 C\right ) \int \frac {1}{c+d \tan (e+f x)}d(d \tan (e+f x))}{d f \left (c^2+d^2\right )}+\frac {d^3 \log (\cos (e+f x)) \left (a^3 (B c-d (A-C))+3 a^2 b (A c+B d-c C)-3 a b^2 (B c-d (A-C))-b^3 (A c+B d-c C)\right )}{f \left (c^2+d^2\right )}-\frac {d^3 x \left (a^3 (A c+B d-c C)-3 a^2 b (B c-d (A-C))-3 a b^2 (A c+B d-c C)+b^3 (B c-d (A-C))\right )}{c^2+d^2}}{d}-\frac {b \tan (e+f x) \left (b d^2 (a B+A b-b C)+(b c-a d) (-a C d-b B d+b c C)\right )}{d f}}{d}+\frac {(-a C d-b B d+b c C) (a+b \tan (e+f x))^2}{2 d f}}{d}\)

\(\Big \downarrow \) 16

\(\displaystyle \frac {C (a+b \tan (e+f x))^3}{3 d f}-\frac {\frac {\frac {\frac {d^3 \log (\cos (e+f x)) \left (a^3 (B c-d (A-C))+3 a^2 b (A c+B d-c C)-3 a b^2 (B c-d (A-C))-b^3 (A c+B d-c C)\right )}{f \left (c^2+d^2\right )}-\frac {d^3 x \left (a^3 (A c+B d-c C)-3 a^2 b (B c-d (A-C))-3 a b^2 (A c+B d-c C)+b^3 (B c-d (A-C))\right )}{c^2+d^2}+\frac {(b c-a d)^3 \left (A d^2-B c d+c^2 C\right ) \log (c+d \tan (e+f x))}{d f \left (c^2+d^2\right )}}{d}-\frac {b \tan (e+f x) \left (b d^2 (a B+A b-b C)+(b c-a d) (-a C d-b B d+b c C)\right )}{d f}}{d}+\frac {(-a C d-b B d+b c C) (a+b \tan (e+f x))^2}{2 d f}}{d}\)

input
Int[((a + b*Tan[e + f*x])^3*(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2))/(c + 
d*Tan[e + f*x]),x]
 
output
(C*(a + b*Tan[e + f*x])^3)/(3*d*f) - (((b*c*C - b*B*d - a*C*d)*(a + b*Tan[ 
e + f*x])^2)/(2*d*f) + ((-((d^3*(a^3*(A*c - c*C + B*d) - 3*a*b^2*(A*c - c* 
C + B*d) - 3*a^2*b*(B*c - (A - C)*d) + b^3*(B*c - (A - C)*d))*x)/(c^2 + d^ 
2)) + (d^3*(3*a^2*b*(A*c - c*C + B*d) - b^3*(A*c - c*C + B*d) + a^3*(B*c - 
 (A - C)*d) - 3*a*b^2*(B*c - (A - C)*d))*Log[Cos[e + f*x]])/((c^2 + d^2)*f 
) + ((b*c - a*d)^3*(c^2*C - B*c*d + A*d^2)*Log[c + d*Tan[e + f*x]])/(d*(c^ 
2 + d^2)*f))/d - (b*(b*(A*b + a*B - b*C)*d^2 + (b*c - a*d)*(b*c*C - b*B*d 
- a*C*d))*Tan[e + f*x])/(d*f))/d)/d
 

3.1.70.3.1 Defintions of rubi rules used

rule 16
Int[(c_.)/((a_.) + (b_.)*(x_)), x_Symbol] :> Simp[c*(Log[RemoveContent[a + 
b*x, x]]/b), x] /; FreeQ[{a, b, c}, x]
 

rule 25
Int[-(Fx_), x_Symbol] :> Simp[Identity[-1]   Int[Fx, x], x]
 

rule 27
Int[(a_)*(Fx_), x_Symbol] :> Simp[a   Int[Fx, x], x] /; FreeQ[a, x] &&  !Ma 
tchQ[Fx, (b_)*(Gx_) /; FreeQ[b, x]]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 3956
Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d 
*x], x]]/d, x] /; FreeQ[{c, d}, x]
 

rule 4100
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_) + (C_.)*tan[(e_.) + 
 (f_.)*(x_)]^2), x_Symbol] :> Simp[A/(b*f)   Subst[Int[(a + x)^m, x], x, b* 
Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, A, C, m}, x] && EqQ[A, C]
 

rule 4109
Int[((A_) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2 
)/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*A + b*B - a 
*C)*(x/(a^2 + b^2)), x] + (Simp[(A*b^2 - a*b*B + a^2*C)/(a^2 + b^2)   Int[( 
1 + Tan[e + f*x]^2)/(a + b*Tan[e + f*x]), x], x] - Simp[(A*b - a*B - b*C)/( 
a^2 + b^2)   Int[Tan[e + f*x], x], x]) /; FreeQ[{a, b, e, f, A, B, C}, x] & 
& NeQ[A*b^2 - a*b*B + a^2*C, 0] && NeQ[a^2 + b^2, 0] && NeQ[A*b - a*B - b*C 
, 0]
 

rule 4120
Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.) 
*(x_)])^(n_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f 
_.)*(x_)]^2), x_Symbol] :> Simp[b*C*Tan[e + f*x]*((c + d*Tan[e + f*x])^(n + 
 1)/(d*f*(n + 2))), x] - Simp[1/(d*(n + 2))   Int[(c + d*Tan[e + f*x])^n*Si 
mp[b*c*C - a*A*d*(n + 2) - (A*b + a*B - b*C)*d*(n + 2)*Tan[e + f*x] - (a*C* 
d*(n + 2) - b*(c*C - B*d*(n + 2)))*Tan[e + f*x]^2, x], x], x] /; FreeQ[{a, 
b, c, d, e, f, A, B, C, n}, x] && NeQ[b*c - a*d, 0] && NeQ[c^2 + d^2, 0] && 
  !LtQ[n, -1]
 

rule 4130
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((c_.) + (d_.)*tan[(e_.) 
+ (f_.)*(x_)])^(n_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_. 
) + (f_.)*(x_)]^2), x_Symbol] :> Simp[C*(a + b*Tan[e + f*x])^m*((c + d*Tan[ 
e + f*x])^(n + 1)/(d*f*(m + n + 1))), x] + Simp[1/(d*(m + n + 1))   Int[(a 
+ b*Tan[e + f*x])^(m - 1)*(c + d*Tan[e + f*x])^n*Simp[a*A*d*(m + n + 1) - C 
*(b*c*m + a*d*(n + 1)) + d*(A*b + a*B - b*C)*(m + n + 1)*Tan[e + f*x] - (C* 
m*(b*c - a*d) - b*B*d*(m + n + 1))*Tan[e + f*x]^2, x], x], x] /; FreeQ[{a, 
b, c, d, e, f, A, B, C, n}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && 
 NeQ[c^2 + d^2, 0] && GtQ[m, 0] &&  !(IGtQ[n, 0] && ( !IntegerQ[m] || (EqQ[ 
c, 0] && NeQ[a, 0])))
 
3.1.70.4 Maple [A] (verified)

Time = 0.24 (sec) , antiderivative size = 500, normalized size of antiderivative = 1.48

method result size
norman \(\frac {\left (A \,a^{3} c +3 A \,a^{2} b d -3 A a \,b^{2} c -A \,b^{3} d +B \,a^{3} d -3 B \,a^{2} b c -3 B a \,b^{2} d +B \,b^{3} c -C \,a^{3} c -3 C \,a^{2} b d +3 C a \,b^{2} c +C \,b^{3} d \right ) x}{c^{2}+d^{2}}+\frac {\left (A \,b^{2} d^{2}+3 B a b \,d^{2}-B \,b^{2} c d +3 a^{2} C \,d^{2}-3 C a b c d +C \,b^{2} c^{2}-C \,b^{2} d^{2}\right ) b \tan \left (f x +e \right )}{f \,d^{3}}+\frac {C \,b^{3} \tan \left (f x +e \right )^{3}}{3 d f}+\frac {b^{2} \left (b d B +3 C a d -C b c \right ) \tan \left (f x +e \right )^{2}}{2 d^{2} f}+\frac {\left (A \,d^{5} a^{3}-3 A b c \,d^{4} a^{2}+3 A \,b^{2} c^{2} d^{3} a -A \,b^{3} c^{3} d^{2}-B c \,d^{4} a^{3}+3 B b \,c^{2} d^{3} a^{2}-3 B \,b^{2} c^{3} a \,d^{2}+B \,b^{3} c^{4} d +C \,c^{2} d^{3} a^{3}-3 C b \,c^{3} a^{2} d^{2}+3 C a \,b^{2} c^{4} d -C \,b^{3} c^{5}\right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right ) d^{4} f}-\frac {\left (A \,a^{3} d -3 A \,a^{2} b c -3 A a \,b^{2} d +A \,b^{3} c -B \,a^{3} c -3 B \,a^{2} b d +3 B a \,b^{2} c +B \,b^{3} d -a^{3} C d +3 C \,a^{2} b c +3 C a \,b^{2} d -C \,b^{3} c \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f \left (c^{2}+d^{2}\right )}\) \(500\)
derivativedivides \(\frac {\frac {b \left (\frac {C \,b^{2} d^{2} \tan \left (f x +e \right )^{3}}{3}+\frac {B \,b^{2} d^{2} \tan \left (f x +e \right )^{2}}{2}+\frac {3 C a b \,d^{2} \tan \left (f x +e \right )^{2}}{2}-\frac {C \,b^{2} c d \tan \left (f x +e \right )^{2}}{2}+\tan \left (f x +e \right ) A \,b^{2} d^{2}+3 \tan \left (f x +e \right ) B a b \,d^{2}-\tan \left (f x +e \right ) B \,b^{2} c d +3 \tan \left (f x +e \right ) a^{2} C \,d^{2}-3 \tan \left (f x +e \right ) C a b c d +\tan \left (f x +e \right ) C \,b^{2} c^{2}-\tan \left (f x +e \right ) C \,b^{2} d^{2}\right )}{d^{3}}+\frac {\frac {\left (-A \,a^{3} d +3 A \,a^{2} b c +3 A a \,b^{2} d -A \,b^{3} c +B \,a^{3} c +3 B \,a^{2} b d -3 B a \,b^{2} c -B \,b^{3} d +a^{3} C d -3 C \,a^{2} b c -3 C a \,b^{2} d +C \,b^{3} c \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A \,a^{3} c +3 A \,a^{2} b d -3 A a \,b^{2} c -A \,b^{3} d +B \,a^{3} d -3 B \,a^{2} b c -3 B a \,b^{2} d +B \,b^{3} c -C \,a^{3} c -3 C \,a^{2} b d +3 C a \,b^{2} c +C \,b^{3} d \right ) \arctan \left (\tan \left (f x +e \right )\right )}{c^{2}+d^{2}}+\frac {\left (A \,d^{5} a^{3}-3 A b c \,d^{4} a^{2}+3 A \,b^{2} c^{2} d^{3} a -A \,b^{3} c^{3} d^{2}-B c \,d^{4} a^{3}+3 B b \,c^{2} d^{3} a^{2}-3 B \,b^{2} c^{3} a \,d^{2}+B \,b^{3} c^{4} d +C \,c^{2} d^{3} a^{3}-3 C b \,c^{3} a^{2} d^{2}+3 C a \,b^{2} c^{4} d -C \,b^{3} c^{5}\right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{d^{4} \left (c^{2}+d^{2}\right )}}{f}\) \(542\)
default \(\frac {\frac {b \left (\frac {C \,b^{2} d^{2} \tan \left (f x +e \right )^{3}}{3}+\frac {B \,b^{2} d^{2} \tan \left (f x +e \right )^{2}}{2}+\frac {3 C a b \,d^{2} \tan \left (f x +e \right )^{2}}{2}-\frac {C \,b^{2} c d \tan \left (f x +e \right )^{2}}{2}+\tan \left (f x +e \right ) A \,b^{2} d^{2}+3 \tan \left (f x +e \right ) B a b \,d^{2}-\tan \left (f x +e \right ) B \,b^{2} c d +3 \tan \left (f x +e \right ) a^{2} C \,d^{2}-3 \tan \left (f x +e \right ) C a b c d +\tan \left (f x +e \right ) C \,b^{2} c^{2}-\tan \left (f x +e \right ) C \,b^{2} d^{2}\right )}{d^{3}}+\frac {\frac {\left (-A \,a^{3} d +3 A \,a^{2} b c +3 A a \,b^{2} d -A \,b^{3} c +B \,a^{3} c +3 B \,a^{2} b d -3 B a \,b^{2} c -B \,b^{3} d +a^{3} C d -3 C \,a^{2} b c -3 C a \,b^{2} d +C \,b^{3} c \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A \,a^{3} c +3 A \,a^{2} b d -3 A a \,b^{2} c -A \,b^{3} d +B \,a^{3} d -3 B \,a^{2} b c -3 B a \,b^{2} d +B \,b^{3} c -C \,a^{3} c -3 C \,a^{2} b d +3 C a \,b^{2} c +C \,b^{3} d \right ) \arctan \left (\tan \left (f x +e \right )\right )}{c^{2}+d^{2}}+\frac {\left (A \,d^{5} a^{3}-3 A b c \,d^{4} a^{2}+3 A \,b^{2} c^{2} d^{3} a -A \,b^{3} c^{3} d^{2}-B c \,d^{4} a^{3}+3 B b \,c^{2} d^{3} a^{2}-3 B \,b^{2} c^{3} a \,d^{2}+B \,b^{3} c^{4} d +C \,c^{2} d^{3} a^{3}-3 C b \,c^{3} a^{2} d^{2}+3 C a \,b^{2} c^{4} d -C \,b^{3} c^{5}\right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{d^{4} \left (c^{2}+d^{2}\right )}}{f}\) \(542\)
parallelrisch \(\text {Expression too large to display}\) \(1038\)
risch \(\text {Expression too large to display}\) \(2490\)

input
int((a+b*tan(f*x+e))^3*(A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e)),x, 
method=_RETURNVERBOSE)
 
output
(A*a^3*c+3*A*a^2*b*d-3*A*a*b^2*c-A*b^3*d+B*a^3*d-3*B*a^2*b*c-3*B*a*b^2*d+B 
*b^3*c-C*a^3*c-3*C*a^2*b*d+3*C*a*b^2*c+C*b^3*d)/(c^2+d^2)*x+(A*b^2*d^2+3*B 
*a*b*d^2-B*b^2*c*d+3*C*a^2*d^2-3*C*a*b*c*d+C*b^2*c^2-C*b^2*d^2)*b/f/d^3*ta 
n(f*x+e)+1/3*C*b^3/d/f*tan(f*x+e)^3+1/2*b^2*(B*b*d+3*C*a*d-C*b*c)/d^2/f*ta 
n(f*x+e)^2+(A*a^3*d^5-3*A*a^2*b*c*d^4+3*A*a*b^2*c^2*d^3-A*b^3*c^3*d^2-B*a^ 
3*c*d^4+3*B*a^2*b*c^2*d^3-3*B*a*b^2*c^3*d^2+B*b^3*c^4*d+C*a^3*c^2*d^3-3*C* 
a^2*b*c^3*d^2+3*C*a*b^2*c^4*d-C*b^3*c^5)/(c^2+d^2)/d^4/f*ln(c+d*tan(f*x+e) 
)-1/2*(A*a^3*d-3*A*a^2*b*c-3*A*a*b^2*d+A*b^3*c-B*a^3*c-3*B*a^2*b*d+3*B*a*b 
^2*c+B*b^3*d-C*a^3*d+3*C*a^2*b*c+3*C*a*b^2*d-C*b^3*c)/f/(c^2+d^2)*ln(1+tan 
(f*x+e)^2)
 
3.1.70.5 Fricas [A] (verification not implemented)

Time = 0.77 (sec) , antiderivative size = 627, normalized size of antiderivative = 1.86 \[ \int \frac {(a+b \tan (e+f x))^3 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{c+d \tan (e+f x)} \, dx=\frac {2 \, {\left (C b^{3} c^{2} d^{3} + C b^{3} d^{5}\right )} \tan \left (f x + e\right )^{3} + 6 \, {\left ({\left ({\left (A - C\right )} a^{3} - 3 \, B a^{2} b - 3 \, {\left (A - C\right )} a b^{2} + B b^{3}\right )} c d^{4} + {\left (B a^{3} + 3 \, {\left (A - C\right )} a^{2} b - 3 \, B a b^{2} - {\left (A - C\right )} b^{3}\right )} d^{5}\right )} f x - 3 \, {\left (C b^{3} c^{3} d^{2} + C b^{3} c d^{4} - {\left (3 \, C a b^{2} + B b^{3}\right )} c^{2} d^{3} - {\left (3 \, C a b^{2} + B b^{3}\right )} d^{5}\right )} \tan \left (f x + e\right )^{2} - 3 \, {\left (C b^{3} c^{5} - A a^{3} d^{5} - {\left (3 \, C a b^{2} + B b^{3}\right )} c^{4} d + {\left (3 \, C a^{2} b + 3 \, B a b^{2} + A b^{3}\right )} c^{3} d^{2} - {\left (C a^{3} + 3 \, B a^{2} b + 3 \, A a b^{2}\right )} c^{2} d^{3} + {\left (B a^{3} + 3 \, A a^{2} b\right )} c d^{4}\right )} \log \left (\frac {d^{2} \tan \left (f x + e\right )^{2} + 2 \, c d \tan \left (f x + e\right ) + c^{2}}{\tan \left (f x + e\right )^{2} + 1}\right ) + 3 \, {\left (C b^{3} c^{5} - {\left (3 \, C a b^{2} + B b^{3}\right )} c^{4} d + {\left (3 \, C a^{2} b + 3 \, B a b^{2} + A b^{3}\right )} c^{3} d^{2} - {\left (C a^{3} + 3 \, B a^{2} b + 3 \, A a b^{2}\right )} c^{2} d^{3} + {\left (3 \, C a^{2} b + 3 \, B a b^{2} + {\left (A - C\right )} b^{3}\right )} c d^{4} - {\left (C a^{3} + 3 \, B a^{2} b + 3 \, {\left (A - C\right )} a b^{2} - B b^{3}\right )} d^{5}\right )} \log \left (\frac {1}{\tan \left (f x + e\right )^{2} + 1}\right ) + 6 \, {\left (C b^{3} c^{4} d - {\left (3 \, C a b^{2} + B b^{3}\right )} c^{3} d^{2} + {\left (3 \, C a^{2} b + 3 \, B a b^{2} + A b^{3}\right )} c^{2} d^{3} - {\left (3 \, C a b^{2} + B b^{3}\right )} c d^{4} + {\left (3 \, C a^{2} b + 3 \, B a b^{2} + {\left (A - C\right )} b^{3}\right )} d^{5}\right )} \tan \left (f x + e\right )}{6 \, {\left (c^{2} d^{4} + d^{6}\right )} f} \]

input
integrate((a+b*tan(f*x+e))^3*(A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+ 
e)),x, algorithm="fricas")
 
output
1/6*(2*(C*b^3*c^2*d^3 + C*b^3*d^5)*tan(f*x + e)^3 + 6*(((A - C)*a^3 - 3*B* 
a^2*b - 3*(A - C)*a*b^2 + B*b^3)*c*d^4 + (B*a^3 + 3*(A - C)*a^2*b - 3*B*a* 
b^2 - (A - C)*b^3)*d^5)*f*x - 3*(C*b^3*c^3*d^2 + C*b^3*c*d^4 - (3*C*a*b^2 
+ B*b^3)*c^2*d^3 - (3*C*a*b^2 + B*b^3)*d^5)*tan(f*x + e)^2 - 3*(C*b^3*c^5 
- A*a^3*d^5 - (3*C*a*b^2 + B*b^3)*c^4*d + (3*C*a^2*b + 3*B*a*b^2 + A*b^3)* 
c^3*d^2 - (C*a^3 + 3*B*a^2*b + 3*A*a*b^2)*c^2*d^3 + (B*a^3 + 3*A*a^2*b)*c* 
d^4)*log((d^2*tan(f*x + e)^2 + 2*c*d*tan(f*x + e) + c^2)/(tan(f*x + e)^2 + 
 1)) + 3*(C*b^3*c^5 - (3*C*a*b^2 + B*b^3)*c^4*d + (3*C*a^2*b + 3*B*a*b^2 + 
 A*b^3)*c^3*d^2 - (C*a^3 + 3*B*a^2*b + 3*A*a*b^2)*c^2*d^3 + (3*C*a^2*b + 3 
*B*a*b^2 + (A - C)*b^3)*c*d^4 - (C*a^3 + 3*B*a^2*b + 3*(A - C)*a*b^2 - B*b 
^3)*d^5)*log(1/(tan(f*x + e)^2 + 1)) + 6*(C*b^3*c^4*d - (3*C*a*b^2 + B*b^3 
)*c^3*d^2 + (3*C*a^2*b + 3*B*a*b^2 + A*b^3)*c^2*d^3 - (3*C*a*b^2 + B*b^3)* 
c*d^4 + (3*C*a^2*b + 3*B*a*b^2 + (A - C)*b^3)*d^5)*tan(f*x + e))/((c^2*d^4 
 + d^6)*f)
 
3.1.70.6 Sympy [C] (verification not implemented)

Result contains complex when optimal does not.

Time = 20.49 (sec) , antiderivative size = 7096, normalized size of antiderivative = 21.06 \[ \int \frac {(a+b \tan (e+f x))^3 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{c+d \tan (e+f x)} \, dx=\text {Too large to display} \]

input
integrate((a+b*tan(f*x+e))**3*(A+B*tan(f*x+e)+C*tan(f*x+e)**2)/(c+d*tan(f* 
x+e)),x)
 
output
Piecewise((zoo*x*(a + b*tan(e))**3*(A + B*tan(e) + C*tan(e)**2)/tan(e), Eq 
(c, 0) & Eq(d, 0) & Eq(f, 0)), ((A*a**3*x + 3*A*a**2*b*log(tan(e + f*x)**2 
 + 1)/(2*f) - 3*A*a*b**2*x + 3*A*a*b**2*tan(e + f*x)/f - A*b**3*log(tan(e 
+ f*x)**2 + 1)/(2*f) + A*b**3*tan(e + f*x)**2/(2*f) + B*a**3*log(tan(e + f 
*x)**2 + 1)/(2*f) - 3*B*a**2*b*x + 3*B*a**2*b*tan(e + f*x)/f - 3*B*a*b**2* 
log(tan(e + f*x)**2 + 1)/(2*f) + 3*B*a*b**2*tan(e + f*x)**2/(2*f) + B*b**3 
*x + B*b**3*tan(e + f*x)**3/(3*f) - B*b**3*tan(e + f*x)/f - C*a**3*x + C*a 
**3*tan(e + f*x)/f - 3*C*a**2*b*log(tan(e + f*x)**2 + 1)/(2*f) + 3*C*a**2* 
b*tan(e + f*x)**2/(2*f) + 3*C*a*b**2*x + C*a*b**2*tan(e + f*x)**3/f - 3*C* 
a*b**2*tan(e + f*x)/f + C*b**3*log(tan(e + f*x)**2 + 1)/(2*f) + C*b**3*tan 
(e + f*x)**4/(4*f) - C*b**3*tan(e + f*x)**2/(2*f))/c, Eq(d, 0)), (3*I*A*a* 
*3*f*x*tan(e + f*x)/(6*d*f*tan(e + f*x) - 6*I*d*f) + 3*A*a**3*f*x/(6*d*f*t 
an(e + f*x) - 6*I*d*f) + 3*I*A*a**3/(6*d*f*tan(e + f*x) - 6*I*d*f) + 9*A*a 
**2*b*f*x*tan(e + f*x)/(6*d*f*tan(e + f*x) - 6*I*d*f) - 9*I*A*a**2*b*f*x/( 
6*d*f*tan(e + f*x) - 6*I*d*f) - 9*A*a**2*b/(6*d*f*tan(e + f*x) - 6*I*d*f) 
+ 9*I*A*a*b**2*f*x*tan(e + f*x)/(6*d*f*tan(e + f*x) - 6*I*d*f) + 9*A*a*b** 
2*f*x/(6*d*f*tan(e + f*x) - 6*I*d*f) + 9*A*a*b**2*log(tan(e + f*x)**2 + 1) 
*tan(e + f*x)/(6*d*f*tan(e + f*x) - 6*I*d*f) - 9*I*A*a*b**2*log(tan(e + f* 
x)**2 + 1)/(6*d*f*tan(e + f*x) - 6*I*d*f) - 9*I*A*a*b**2/(6*d*f*tan(e + f* 
x) - 6*I*d*f) - 9*A*b**3*f*x*tan(e + f*x)/(6*d*f*tan(e + f*x) - 6*I*d*f...
 
3.1.70.7 Maxima [A] (verification not implemented)

Time = 0.47 (sec) , antiderivative size = 445, normalized size of antiderivative = 1.32 \[ \int \frac {(a+b \tan (e+f x))^3 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{c+d \tan (e+f x)} \, dx=\frac {\frac {6 \, {\left ({\left ({\left (A - C\right )} a^{3} - 3 \, B a^{2} b - 3 \, {\left (A - C\right )} a b^{2} + B b^{3}\right )} c + {\left (B a^{3} + 3 \, {\left (A - C\right )} a^{2} b - 3 \, B a b^{2} - {\left (A - C\right )} b^{3}\right )} d\right )} {\left (f x + e\right )}}{c^{2} + d^{2}} - \frac {6 \, {\left (C b^{3} c^{5} - A a^{3} d^{5} - {\left (3 \, C a b^{2} + B b^{3}\right )} c^{4} d + {\left (3 \, C a^{2} b + 3 \, B a b^{2} + A b^{3}\right )} c^{3} d^{2} - {\left (C a^{3} + 3 \, B a^{2} b + 3 \, A a b^{2}\right )} c^{2} d^{3} + {\left (B a^{3} + 3 \, A a^{2} b\right )} c d^{4}\right )} \log \left (d \tan \left (f x + e\right ) + c\right )}{c^{2} d^{4} + d^{6}} + \frac {3 \, {\left ({\left (B a^{3} + 3 \, {\left (A - C\right )} a^{2} b - 3 \, B a b^{2} - {\left (A - C\right )} b^{3}\right )} c - {\left ({\left (A - C\right )} a^{3} - 3 \, B a^{2} b - 3 \, {\left (A - C\right )} a b^{2} + B b^{3}\right )} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{2} + d^{2}} + \frac {2 \, C b^{3} d^{2} \tan \left (f x + e\right )^{3} - 3 \, {\left (C b^{3} c d - {\left (3 \, C a b^{2} + B b^{3}\right )} d^{2}\right )} \tan \left (f x + e\right )^{2} + 6 \, {\left (C b^{3} c^{2} - {\left (3 \, C a b^{2} + B b^{3}\right )} c d + {\left (3 \, C a^{2} b + 3 \, B a b^{2} + {\left (A - C\right )} b^{3}\right )} d^{2}\right )} \tan \left (f x + e\right )}{d^{3}}}{6 \, f} \]

input
integrate((a+b*tan(f*x+e))^3*(A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+ 
e)),x, algorithm="maxima")
 
output
1/6*(6*(((A - C)*a^3 - 3*B*a^2*b - 3*(A - C)*a*b^2 + B*b^3)*c + (B*a^3 + 3 
*(A - C)*a^2*b - 3*B*a*b^2 - (A - C)*b^3)*d)*(f*x + e)/(c^2 + d^2) - 6*(C* 
b^3*c^5 - A*a^3*d^5 - (3*C*a*b^2 + B*b^3)*c^4*d + (3*C*a^2*b + 3*B*a*b^2 + 
 A*b^3)*c^3*d^2 - (C*a^3 + 3*B*a^2*b + 3*A*a*b^2)*c^2*d^3 + (B*a^3 + 3*A*a 
^2*b)*c*d^4)*log(d*tan(f*x + e) + c)/(c^2*d^4 + d^6) + 3*((B*a^3 + 3*(A - 
C)*a^2*b - 3*B*a*b^2 - (A - C)*b^3)*c - ((A - C)*a^3 - 3*B*a^2*b - 3*(A - 
C)*a*b^2 + B*b^3)*d)*log(tan(f*x + e)^2 + 1)/(c^2 + d^2) + (2*C*b^3*d^2*ta 
n(f*x + e)^3 - 3*(C*b^3*c*d - (3*C*a*b^2 + B*b^3)*d^2)*tan(f*x + e)^2 + 6* 
(C*b^3*c^2 - (3*C*a*b^2 + B*b^3)*c*d + (3*C*a^2*b + 3*B*a*b^2 + (A - C)*b^ 
3)*d^2)*tan(f*x + e))/d^3)/f
 
3.1.70.8 Giac [A] (verification not implemented)

Time = 0.96 (sec) , antiderivative size = 559, normalized size of antiderivative = 1.66 \[ \int \frac {(a+b \tan (e+f x))^3 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{c+d \tan (e+f x)} \, dx=\frac {\frac {6 \, {\left (A a^{3} c - C a^{3} c - 3 \, B a^{2} b c - 3 \, A a b^{2} c + 3 \, C a b^{2} c + B b^{3} c + B a^{3} d + 3 \, A a^{2} b d - 3 \, C a^{2} b d - 3 \, B a b^{2} d - A b^{3} d + C b^{3} d\right )} {\left (f x + e\right )}}{c^{2} + d^{2}} + \frac {3 \, {\left (B a^{3} c + 3 \, A a^{2} b c - 3 \, C a^{2} b c - 3 \, B a b^{2} c - A b^{3} c + C b^{3} c - A a^{3} d + C a^{3} d + 3 \, B a^{2} b d + 3 \, A a b^{2} d - 3 \, C a b^{2} d - B b^{3} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{2} + d^{2}} - \frac {6 \, {\left (C b^{3} c^{5} - 3 \, C a b^{2} c^{4} d - B b^{3} c^{4} d + 3 \, C a^{2} b c^{3} d^{2} + 3 \, B a b^{2} c^{3} d^{2} + A b^{3} c^{3} d^{2} - C a^{3} c^{2} d^{3} - 3 \, B a^{2} b c^{2} d^{3} - 3 \, A a b^{2} c^{2} d^{3} + B a^{3} c d^{4} + 3 \, A a^{2} b c d^{4} - A a^{3} d^{5}\right )} \log \left ({\left | d \tan \left (f x + e\right ) + c \right |}\right )}{c^{2} d^{4} + d^{6}} + \frac {2 \, C b^{3} d^{2} \tan \left (f x + e\right )^{3} - 3 \, C b^{3} c d \tan \left (f x + e\right )^{2} + 9 \, C a b^{2} d^{2} \tan \left (f x + e\right )^{2} + 3 \, B b^{3} d^{2} \tan \left (f x + e\right )^{2} + 6 \, C b^{3} c^{2} \tan \left (f x + e\right ) - 18 \, C a b^{2} c d \tan \left (f x + e\right ) - 6 \, B b^{3} c d \tan \left (f x + e\right ) + 18 \, C a^{2} b d^{2} \tan \left (f x + e\right ) + 18 \, B a b^{2} d^{2} \tan \left (f x + e\right ) + 6 \, A b^{3} d^{2} \tan \left (f x + e\right ) - 6 \, C b^{3} d^{2} \tan \left (f x + e\right )}{d^{3}}}{6 \, f} \]

input
integrate((a+b*tan(f*x+e))^3*(A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+ 
e)),x, algorithm="giac")
 
output
1/6*(6*(A*a^3*c - C*a^3*c - 3*B*a^2*b*c - 3*A*a*b^2*c + 3*C*a*b^2*c + B*b^ 
3*c + B*a^3*d + 3*A*a^2*b*d - 3*C*a^2*b*d - 3*B*a*b^2*d - A*b^3*d + C*b^3* 
d)*(f*x + e)/(c^2 + d^2) + 3*(B*a^3*c + 3*A*a^2*b*c - 3*C*a^2*b*c - 3*B*a* 
b^2*c - A*b^3*c + C*b^3*c - A*a^3*d + C*a^3*d + 3*B*a^2*b*d + 3*A*a*b^2*d 
- 3*C*a*b^2*d - B*b^3*d)*log(tan(f*x + e)^2 + 1)/(c^2 + d^2) - 6*(C*b^3*c^ 
5 - 3*C*a*b^2*c^4*d - B*b^3*c^4*d + 3*C*a^2*b*c^3*d^2 + 3*B*a*b^2*c^3*d^2 
+ A*b^3*c^3*d^2 - C*a^3*c^2*d^3 - 3*B*a^2*b*c^2*d^3 - 3*A*a*b^2*c^2*d^3 + 
B*a^3*c*d^4 + 3*A*a^2*b*c*d^4 - A*a^3*d^5)*log(abs(d*tan(f*x + e) + c))/(c 
^2*d^4 + d^6) + (2*C*b^3*d^2*tan(f*x + e)^3 - 3*C*b^3*c*d*tan(f*x + e)^2 + 
 9*C*a*b^2*d^2*tan(f*x + e)^2 + 3*B*b^3*d^2*tan(f*x + e)^2 + 6*C*b^3*c^2*t 
an(f*x + e) - 18*C*a*b^2*c*d*tan(f*x + e) - 6*B*b^3*c*d*tan(f*x + e) + 18* 
C*a^2*b*d^2*tan(f*x + e) + 18*B*a*b^2*d^2*tan(f*x + e) + 6*A*b^3*d^2*tan(f 
*x + e) - 6*C*b^3*d^2*tan(f*x + e))/d^3)/f
 
3.1.70.9 Mupad [B] (verification not implemented)

Time = 12.13 (sec) , antiderivative size = 508, normalized size of antiderivative = 1.51 \[ \int \frac {(a+b \tan (e+f x))^3 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{c+d \tan (e+f x)} \, dx=\frac {{\mathrm {tan}\left (e+f\,x\right )}^2\,\left (\frac {B\,b^3+3\,C\,a\,b^2}{2\,d}-\frac {C\,b^3\,c}{2\,d^2}\right )}{f}-\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (\frac {c\,\left (\frac {B\,b^3+3\,C\,a\,b^2}{d}-\frac {C\,b^3\,c}{d^2}\right )}{d}-\frac {3\,C\,a^2\,b+3\,B\,a\,b^2+A\,b^3}{d}+\frac {C\,b^3}{d}\right )}{f}-\frac {\ln \left (c+d\,\mathrm {tan}\left (e+f\,x\right )\right )\,\left (d^4\,\left (B\,c\,a^3+3\,A\,b\,c\,a^2\right )-d^3\,\left (C\,a^3\,c^2+3\,B\,a^2\,b\,c^2+3\,A\,a\,b^2\,c^2\right )+d^2\,\left (3\,C\,a^2\,b\,c^3+3\,B\,a\,b^2\,c^3+A\,b^3\,c^3\right )-d\,\left (B\,b^3\,c^4+3\,C\,a\,b^2\,c^4\right )-A\,a^3\,d^5+C\,b^3\,c^5\right )}{f\,\left (c^2\,d^4+d^6\right )}-\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (A\,a^3+A\,b^3\,1{}\mathrm {i}-B\,a^3\,1{}\mathrm {i}+B\,b^3-C\,a^3-C\,b^3\,1{}\mathrm {i}-3\,A\,a\,b^2-A\,a^2\,b\,3{}\mathrm {i}+B\,a\,b^2\,3{}\mathrm {i}-3\,B\,a^2\,b+3\,C\,a\,b^2+C\,a^2\,b\,3{}\mathrm {i}\right )}{2\,f\,\left (d+c\,1{}\mathrm {i}\right )}-\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )-\mathrm {i}\right )\,\left (A\,b^3-B\,a^3-C\,b^3-3\,A\,a^2\,b+3\,B\,a\,b^2+3\,C\,a^2\,b+A\,a^3\,1{}\mathrm {i}+B\,b^3\,1{}\mathrm {i}-C\,a^3\,1{}\mathrm {i}-A\,a\,b^2\,3{}\mathrm {i}-B\,a^2\,b\,3{}\mathrm {i}+C\,a\,b^2\,3{}\mathrm {i}\right )}{2\,f\,\left (c+d\,1{}\mathrm {i}\right )}+\frac {C\,b^3\,{\mathrm {tan}\left (e+f\,x\right )}^3}{3\,d\,f} \]

input
int(((a + b*tan(e + f*x))^3*(A + B*tan(e + f*x) + C*tan(e + f*x)^2))/(c + 
d*tan(e + f*x)),x)
 
output
(tan(e + f*x)^2*((B*b^3 + 3*C*a*b^2)/(2*d) - (C*b^3*c)/(2*d^2)))/f - (tan( 
e + f*x)*((c*((B*b^3 + 3*C*a*b^2)/d - (C*b^3*c)/d^2))/d - (A*b^3 + 3*B*a*b 
^2 + 3*C*a^2*b)/d + (C*b^3)/d))/f - (log(c + d*tan(e + f*x))*(d^4*(B*a^3*c 
 + 3*A*a^2*b*c) - d^3*(C*a^3*c^2 + 3*A*a*b^2*c^2 + 3*B*a^2*b*c^2) + d^2*(A 
*b^3*c^3 + 3*B*a*b^2*c^3 + 3*C*a^2*b*c^3) - d*(B*b^3*c^4 + 3*C*a*b^2*c^4) 
- A*a^3*d^5 + C*b^3*c^5))/(f*(d^6 + c^2*d^4)) - (log(tan(e + f*x) + 1i)*(A 
*a^3 + A*b^3*1i - B*a^3*1i + B*b^3 - C*a^3 - C*b^3*1i - 3*A*a*b^2 - A*a^2* 
b*3i + B*a*b^2*3i - 3*B*a^2*b + 3*C*a*b^2 + C*a^2*b*3i))/(2*f*(c*1i + d)) 
- (log(tan(e + f*x) - 1i)*(A*a^3*1i + A*b^3 - B*a^3 + B*b^3*1i - C*a^3*1i 
- C*b^3 - A*a*b^2*3i - 3*A*a^2*b + 3*B*a*b^2 - B*a^2*b*3i + C*a*b^2*3i + 3 
*C*a^2*b))/(2*f*(c + d*1i)) + (C*b^3*tan(e + f*x)^3)/(3*d*f)